package org.codeart.map.controller;

import com.alibaba.fastjson.JSONObject;
import org.codeart.common.util.R;
import org.codeart.map.service.MapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/service")
public class ServiceController {
    
    @Autowired
    private MapService mapService;

    /**
     * 创建服务
     * @return
     */
    @PostMapping("/add")
    public R<JSONObject> add(@RequestParam("name") String name) {
        Integer sid = mapService.add(name);
        if (sid != null) {
            JSONObject data = new JSONObject();
            data.put("sid", sid);
            return R.ok(data);
        }
        return R.fail();
    }

}
